{include file="../../../application/convert/view/index/head" /}
<style type="text/css">
    .layui-table td, .layui-table th{text-align:left;}
    .layui-table tbody tr.no{background-color:#f00;color:#fff;}
</style>
<div class="install-box">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>待转换数据库配置</legend>
    </fieldset>
    <form class="layui-form layui-form-pane" action="?step=3" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">待转换系统</label>
            <div class="layui-input-inline w200">
                <select name="cmsname">
                    <option value="maccms8x">苹果cmsV8</option>
                    <option value="seacms">海洋cms</option>
                    <option value="ffcms">飞飞cms</option>
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">请务必根据待转换系统真实情况选择</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">服务器地址</label>
            <div class="layui-input-inline w200">
                <input type="text" class="layui-input" name="hostname" lay-verify="title" value="127.0.0.1">
            </div>
            <div class="layui-form-mid layui-word-aux">数据库服务器地址，一般为127.0.0.1</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">数据库端口</label>
            <div class="layui-input-inline w200">
                <input type="text" class="layui-input" name="hostport" lay-verify="title" value="3306">
            </div>
            <div class="layui-form-mid layui-word-aux">系统数据库端口，一般为3306</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">数据库名称</label>
            <div class="layui-input-inline w200">
                <input type="text" class="layui-input" name="database" lay-verify="title">
            </div>
            <div class="layui-form-mid layui-word-aux">系统数据库名,必须包含字母</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">数据库账号</label>
            <div class="layui-input-inline w200">
                <input type="text" class="layui-input" name="username" lay-verify="title">
            </div>
            <div class="layui-form-mid layui-word-aux">连接数据库的用户名</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">数据库密码</label>
            <div class="layui-input-inline w200">
                <input type="password" class="layui-input" name="password" lay-verify="title">
            </div>
            <div class="layui-form-mid layui-word-aux">连接数据库的密码</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">数据库前缀</label>
            <div class="layui-input-inline w200">
                <input type="text" class="layui-input" name="prefix" lay-verify="title" value="mac_">
            </div>
            <div class="layui-form-mid layui-word-aux">根据待转数据库情况</div>
        </div>

        <div class="layui-form-item">
            <button type="submit" class="layui-btn fl" style="margin-left:120px;" lay-submit="" lay-filter="formTest">测试数据连接</button>
            <div class="layui-form-mid layui-word-aux">请先点击 【测试数据连接】 再转换</div>
        </div>
    </form>
    <form class="layui-form layui-form-pane" action="?step=4" method="post">
        <div class="step-btns">
            <a href="?step=1" class="layui-btn layui-btn-primary layui-btn-big fl">返回上一步</a>
            <button type="submit" class="layui-btn layui-btn-big layui-btn-normal fr" lay-submit="" lay-filter="formSubmit" >开始转换</button>
        </div>
    </form>
</div>
{include file="../../../application/convert/view/index/foot" /}
<script type="text/javascript">
    var test=0;
    layui.define(['element', 'form'], function(exports) {
        var $ = layui.jquery, layer = layui.layer, form = layui.form;
        form.on('submit(formTest)', function(data) {
            var _form = '';
            if ($(this).attr('data-form')) {
                _form = $($(this).attr('data-form'));
            } else {
                _form = $(this).parents('form');
            }

            layer.msg('数据提交中...',{time:500000});
            $.ajax({
                type: "POST",
                url: _form.attr('action'),
                data: _form.serialize(),
                dataType:'json',
                success: function(res) {
                    if(res.code==1){
                        test=1;
                    }
                    layer.msg(res.msg);
                }
            });
            return false;
        });
        form.on('submit(formSubmit)', function(data) {
            if(test==0){
                layer.msg('请先点击并通过测试数据连接！');
                return false;
            }

        });



    });
</script>